package com.wjh.controller;


import com.wjh.pojo.LeaveApply;
import com.wjh.service.LeaveApplyService;
import com.wjh.utils.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("leave")
public class LeaveController {

    @Resource
    private LeaveApplyService leaveApplyService;

    /**
     * 根据is_ratify判断是否已经批准过了取得所有记录
     * @param pageNum
     * @param pageSize
     * @param isRatify
     * @param leaveType
     * @param name
     * @param ratifyType
     * @return
     */
    @GetMapping("/apply/list")
    public ResponseResult queryLeaveList(Integer pageNum,Integer pageSize,Integer isRatify,Integer leaveType,
                                                    String name,Integer ratifyType,Integer state){

        return leaveApplyService.queryLeaveList(pageNum,pageSize,isRatify,leaveType,name,ratifyType,state);
    }


    /**
     * 批准请假
     * @param leaveApply
     * @return
     */
    @PutMapping("/ratify")
    public ResponseResult ratifyLeave(@RequestBody LeaveApply leaveApply){
        return leaveApplyService.ratifyLeave(leaveApply);
    }


    @DeleteMapping("/del/{id}")
    public ResponseResult delLeaveByIds(@PathVariable("id") List<Integer> id){
        return leaveApplyService.delLeaveByIds(id);
    }
}
